Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix client connection retries, lobby resizing, and lobby joining delays #109

Merged
merged 6 commits into from
May 28, 2024

Conversation

StenAL
Copy link

@StenAL StenAL commented May 27, 2024

This PR includes the following fixes/features:

  • Resizing the game applet while in a lobby no longer causes a layout shift. This was causing the text at the bottom of the screen to get cut off. I've added a red background in the demo video below to better show it off. Notice how after resizing the window, the red background is visible above the lobby background image in the Before demo but not in the After.
Before After
resize-old.mp4
resize-new.webm
  • Clicking the retry connection button in case of connection errors actually retries the connection now and usually works. Previously it did nothing. In the demo below, I restarted the server the clients were connected to. The old behavior is on the left and the new behavior is on the right.
Demo
reconnect.webm
  • Switching between lobbies is now faster, previously there was an up to 15 second delay, probably for DDoS protection.
Before After
lobby-switch-old.webm
lobby-switch-new2.webm

Mostly code in AdCanvas, IPanel and LoadingPanel to understand what
AApplet is doing.
@StenAL StenAL marked this pull request as draft May 27, 2024 06:08
@StenAL StenAL changed the title Features Fix client connection retries, lobby resizing, and lobby joining delays May 27, 2024
StenAL added 5 commits May 27, 2024 09:42
These were helpful in tracking down the layout shift bug fixed in
LobbyPanel in the next commit.
Resizing the applet caused the lobby screen to do a new layout and
since it was using the default LayoutManager (FlowLayout), the panels
were being placed in unintended places. Most other classes explicitly
set the layout manager to null to avoid this, however, looks like this
was overlooked in LobbyPanel.
Previously, this tried to open a new page in the browser, however,
in our environment, appletContext was null and was throwing an
exception.

This was fixed by destroying the game applet and reinitializing it when
the retry button is clicked.

Reinitalizing the applet caused its size to get re-measured which was
leading to layout bugs after retries, this was fixed by hardcoding the
applet width and height in AApplet. Since the whole game is hardcoded
for this size, this does not result in any problems elsewhere.
This revealed artificial delays in joining lobbies, probably as a means
of flood protection. This can be verified by going into a single player
lobby and clicking "Multiplayer", then "Single player" again rapidly and
seeing a blank screen stuck on the sleep timer.
Previously the delay was a ladder of 3 -> 7 -> 15 seconds and switching
between lobbies was annoying. Now it's faster and the change does not
seem to cause any issues. I still opted to keep a one second delay in
case removing the delay would break something.
@StenAL StenAL marked this pull request as ready for review May 27, 2024 06:43
@PhilippvK
Copy link
Owner

very nice changes and thanks for the before/after clips!

@PhilippvK PhilippvK merged commit ee9374e into PhilippvK:master May 28, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants